home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: krotoff@such.srcc.msu.su (Alexander Krotoff)
- Newsgroups: comp.lang.c.moderated,comp.std.c
- Subject: Function returning structure
- Date: 25 Jan 1996 06:45:17 -0600
- Organization: Research Computer Center, Moscow State University
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4e7u0t$ua@solutions.solon.com>
- References: <4e2ki8$l0k@solutions.solon.com> <4e5p2h$6hk@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
- X-Comment-To: Dan Pop
-
- Dan Pop <danpop@mail.cern.ch> wrote:
- : bnelson@netcom.com (Bob Nelson) writes:
-
- : >#include <stdio.h>
- : >
- : >struct T {
- : > char c[81];
- : >};
- : >
- : >struct T func(void)
- : >{
- : > static struct T s = { "returned from func" };
- : >
- : > return s;
- : >}
- : >
- : >int main(void)
- : >{
- : >
- : > printf("%s\n", func().c);
- : > return 0;
- : >}
- :
- : The compiler has to take the address of func().c and pass it to printf.
- : But func().c is not an lvalue, hence its address cannot be taken.
- : I'm not sure this is the only possible interpretation, so I'm crossposting
- : this article to comp.std.c.
-
- As seems to me, there is nothing to complain bout taking an address
- of lvalue. There is implicit conversion from array of T to pointer to T.
- So, I think your example is correct.
-
- --
- Alexander N. Krotoff krotoff@such.srcc.msu.su
- Research Computer Center tel: +7(095)939-2638
- Moscow State University fax: +7(095)939-4430
-